/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package project1;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author haihip
 */
public class Frame {
    public static JFrame homeFrame = null;
    public static AccountView accountView = new AccountView();
    public static AnnounceView announceView = new AnnounceView();
    public static ChatView chatView = new ChatView();
    public static InBoxView inboxView = new InBoxView();
    public static OutBoxView outboxView = new OutBoxView();
    public static HomeView homeView = new HomeView();
    public static ManagerSubjectView managerView = new ManagerSubjectView();
    public static MarkView markView = new MarkView();
    public static RegisterSubjectView registerView = new RegisterSubjectView();
    public static GVProjectView gvProjectView = new GVProjectView();
    public static GVHomeView gvHomeView = new GVHomeView();
    private static Func func= new Func();
    public static String URLServer = func.loadURLServer();
    public Frame()
    {
        
        homeFrame = new JFrame();
        homeFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        homeFrame.pack();
        homeFrame.setTitle("Phần mềm quản lý học tập");
        homeFrame.setEnabled(false);
        homeFrame.setLocationRelativeTo(null);
        homeFrame.setVisible(false);
        homeFrame.setMinimumSize(new Dimension(1024, 700));
        homeFrame.setMaximumSize(new Dimension(1024, 700));
        homeFrame.setResizable(false);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double width = screenSize.getWidth();
        double height = screenSize.getHeight();
        homeFrame.setLocation((int) (width/2-512), (int) (height/2-350));
        homeFrame.setVisible(true);
        homeFrame.setEnabled(true);
        switch (Project1.User[9]) {
            case "1":
                homeFrame.getContentPane().add(homeView);
                break;
            case "2":
                homeFrame.getContentPane().add(gvHomeView);
                break;
        }
    }
    public static void setFrame(JPanel a)
    {
       homeFrame.getContentPane().removeAll();
       homeFrame.getContentPane().repaint();
       homeFrame.getContentPane().invalidate();
       homeFrame.getContentPane().add(a);
       homeFrame.getContentPane().revalidate();
    }
    
}
